package view.tables;

import java.awt.Component;

import javax.swing.DefaultListCellRenderer;
import javax.swing.JLabel;
import javax.swing.JList;

@SuppressWarnings("serial")
public class IconizedListRenderer extends DefaultListCellRenderer {

	@Override
	public Component getListCellRendererComponent(JList list, Object value,
			int index, boolean isSelected, boolean cellHasFocus) {

		// Get the renderer component from parent class

		JLabel valueList = (JLabel) super.getListCellRendererComponent(list, value,	index, isSelected, cellHasFocus);

		// Get icon to use for the list item value

		if(value instanceof IconizedInterface){
			IconizedInterface a = (IconizedInterface)value;
			
			valueList.setIcon(a.getIcon());
			valueList.setText(a.toString());
			
			return valueList;
		}
		return valueList;
	}

}
